package com.ibeeking.found.open.b.rest.controller.v1;

import com.ibeeking.found.common.annotation.IgnoreResult;
import com.ibeeking.found.open.api.common.dto.StatisticsCarDTO;
import com.ibeeking.found.open.b.rest.service.IParkingService;
import com.ibeeking.found.open.service.common.dto.ParkingResultDTO;
import com.ibeeking.found.open.service.common.param.ParkingParam;
import com.ibeeking.found.open.service.common.query.StatisticsCarQuery;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName ParkingController控制器
 * @Description
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/v1/open/api/parking")
public class ParkingController {

    @Resource
    private IParkingService parkingServiceImpl;

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "车辆入场推送")
    @PostMapping(value = "/parkIn/{tenantId}")
    @IgnoreResult
    public ParkingResultDTO parkIn(@RequestBody ParkingParam parkingParam, @PathVariable("tenantId") String tenantId) {
        return parkingServiceImpl.parkIn(parkingParam);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "车辆出场推送")
    @PostMapping(value = "/parkOut/{tenantId}")
    @IgnoreResult
    public ParkingResultDTO parkOut(@RequestBody ParkingParam parkingParam, @PathVariable("tenantId") String tenantId) {
        return parkingServiceImpl.parkOut(parkingParam);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "车辆订单支付成功推送")
    @PostMapping(value = "/parkOrder/{tenantId}")
    @IgnoreResult
    public ParkingResultDTO parkOrder(@RequestBody ParkingParam parkingParam, @PathVariable("tenantId") String tenantId) {
        return parkingServiceImpl.parkOrder(parkingParam);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "车辆入场推送")
    @PostMapping(value = "/parkIn")
    @IgnoreResult
    public ParkingResultDTO parkingIn(@RequestBody ParkingParam parkingParam) {
        return parkingServiceImpl.parkIn(parkingParam);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "车辆出场推送")
    @PostMapping(value = "/parkOut")
    @IgnoreResult
    public ParkingResultDTO parkingOut(@RequestBody ParkingParam parkingParam) {
        return parkingServiceImpl.parkOut(parkingParam);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "车辆订单支付成功推送")
    @PostMapping(value = "/parkOrder")
    @IgnoreResult
    public ParkingResultDTO parkingOrder(@RequestBody ParkingParam parkingParam) {
        return parkingServiceImpl.parkOrder(parkingParam);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "车辆缴费推送")
    @PostMapping(value = "/parkCharge")
    @IgnoreResult
    public ParkingResultDTO parkCharge(@RequestBody ParkingParam parkingParam) {
        return parkingServiceImpl.parkCharge(parkingParam);
    }

    @PostMapping(value = "/statisticsCar")
    public List<StatisticsCarDTO> statisticsCar(@RequestBody StatisticsCarQuery query) {
        return parkingServiceImpl.statisticsCar(query);
    }
}
